#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import time
from multiprocessing import Process

class MyProcess(Process):
    def __init__(self, interval):
        super().__init__()
        self.interval = interval
    def run(self):
        print('process(%s) is running...'%os.getpid())
        t_start = time.time()
        time.sleep(self.interval)
        t_stop = time.time()
        print('process(%d) is spent %0.2f seconds to run'%(os.getpid(), t_stop - t_start))
if __name__ == '__main__':
    print('master process(%d) is running...'%os.getpid())
    t_start = time.time()
    p1 = MyProcess(2)
    p1.start()
    p1.join()
    t_stop = time.time()
    print('total spent %0.2f seconds'%(t_stop - t_start))
